﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Reflection;
using JqueryNet.FormControl.FormHtmlControl;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using JqueryNet.FormControl.FormWebControl;

namespace JqueryNet.FormControl
{
    public class ControlFactory
    {
        public static string CLICK = "onclick";
        public static string CHANGE = "onchange";
        public static string BLUR = "onblur";
        public static string DBLCLICK = "ondblclick";
        public static string FOCUS = "onfocus";
        public static string KEYDOWN = "onkeydown";
        public static string KEYPRESS = "onkeypress";
        public static string MOUSEDOWN = "onmousedown";
        public static string MOUSEMOVE = "onmousemove";
        public static string MOUSEOUT = "onmouseout";
        public static string MOUSEOVER = "onmouseover";
        public static string MOUSEUP = "onmouseup";
        public static string KEYUP = "onkeyup";
        public static string SELECT = "onselect";
        public static string SUBMIT = "onsubmit";
        public virtual IJQuery CreateIJquery(Control _control)
        {
            switch (_control.GetType().FullName)
            {
                case "System.Web.UI.HtmlControls.HtmlAnchor":
                    return new JLiteral(GetAsType<Literal>(_control));
                case "System.Web.UI.HtmlControls.HtmlForm":
                    return new JHiddenField(GetAsType<HiddenField>(_control));
                default:
                    return null;
            }
        }

        protected T GetAsType<T>(System.Web.UI.Control _control) where T : Control
        {
            return (T)_control;
        }


    }
}
